package oop2;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Girl
 * Package: oop2
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-21
 * Time: 15:09
 */

public class Girl {
    private String name;
    private int age;

    public void marry(Boy boy) {
        System.out.println("我想嫁给" + boy.getName());

        //this 表示当前对象
        boy.marry(this);
    }

    /**
     * 比较两个Girl对象的大小
     *
     * @param girl
     * @return 正数 当前对象大 负数: 当前对象小  0:相等
     */
    public int compare(Girl girl) {
        //如果当前对象的age 大于 形参对象的age
        if (this.age > girl.age) {
            return 1;
        } else if (this.age < girl.age) {
            return -1;
        } else {
            return 0;
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Girl() {
    }

    public Girl(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
